home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Form 1"
- ClientHeight = 5820
- ClientLeft = 1095
- ClientTop = 1755
- ClientWidth = 7365
- Height = 6510
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 5820
- ScaleWidth = 7365
- Top = 1125
- Width = 7485
- Begin CommandButton Command2
- Caption = "Unload Last Form"
- Height = 465
- Left = 4200
- TabIndex = 2
- Top = 5220
- Width = 2190
- End
- Begin CommandButton Command1
- Caption = "Create New Form"
- Height = 480
- Left = 900
- TabIndex = 1
- Top = 5205
- Width = 1815
- End
- Begin TextBox Text1
- Height = 4725
- Left = 120
- TabIndex = 0
- Text = "This is form 1"
- Top = 165
- Width = 7215
- End
- Begin Menu mnuExit
- Caption = "Exit"
- End
- Sub Command1_Click ()
- 'Increment # of forms created
- iNumForms = iNumForms + 1
- 're-dimension the array
- ReDim Preserve MyForm(iNumForms) As Form1
- 'Refer to new instance of Form1
- Set MyForm(iNumForms) = New Form1
- 'Set the new form's caption
- MyForm(iNumForms).Caption = "Form" + Str$(iNumForms + 1)
- 'Change the new form's text box
- MyForm(iNumForms).Text1 = "This is the text box on Form " + Str$(iNumForms + 1)
- 'Make the menu bar invisible
- MyForm(iNumForms).mnuExit.Visible = False
- 'Set the new form's top and left properties based on
- 'those of the previous form
- If iNumForms > 1 Then
- MyForm(iNumForms).Top = MyForm(iNumForms - 1).Top + 300
- MyForm(iNumForms).Left = MyForm(iNumForms - 1).Left + 200
- Else
- MyForm(iNumForms).Top = Form1.Top + 300
- MyForm(iNumForms).Left = Form1.Left + 200
- End If
- 'Make the new form visible
- MyForm(iNumForms).Show
- End Sub
- Sub Command2_Click ()
- 'Make sure the design time form is not being unloaded
- If iNumForms = 0 Then
- MsgBox "Can't Unload Design-Time Form"
- Exit Sub
- End If
- 'Make the form invisible
- MyForm(iNumForms).Visible = False
- 'Free up the form's resources
- Set MyForm(iNumForms) = Nothing
- 'Set the new # of forms
- iNumForms = iNumForms - 1
- End Sub
- Sub Form_Load ()
- Text1 = "This is the text box on Form 1."
- End Sub
- Sub Form_Unload (Cancel As Integer)
- End
- End Sub
- Sub mnuExit_Click ()
- Unload Me
- End Sub
-